package com.pzh.assignment.common.bean.vo;

import com.pzh.assignment.common.bean.GlobalConstant;
import com.pzh.assignment.entity.CourseType;
import lombok.Data;

import java.time.format.DateTimeFormatter;


@Data
public class CourseTypeVO {
    private Integer id;

    private String name;

    private Integer standardNum;

    private Integer maxNum;

    private String createTime;

    private String updateTime;

    public static CourseTypeVO valueOf(CourseType courseType) {
        CourseTypeVO vo = new CourseTypeVO();
        vo.setId(courseType.getId());
        vo.setName(courseType.getName());
        vo.setStandardNum(courseType.getStandardNum());
        vo.setMaxNum(courseType.getMaxNum());
        if (courseType.getCreateTime() != null) {
            vo.setCreateTime(courseType.getCreateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        if (courseType.getUpdateTime() != null) {
            vo.setUpdateTime(courseType.getUpdateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        return vo;
    }
}
